/*
 * ventanaPrincipal.java
 *
 * Created on 28 de noviembre de 2008, 11:25
 */

package clases;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.util.Collections;
import java.util.Vector;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.FlushModeType;
import javax.persistence.Persistence;
import javax.swing.ImageIcon;

/**
 *
 * @author  USUARIO
 */
public class ventanaPrincipal extends javax.swing.JFrame {


    /** Creates new form ventanaPrincipal */
    public ventanaPrincipal() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dialogoBuscarCriterios = new javax.swing.JDialog();
        cNombre = new javax.swing.JCheckBox();
        cTipo = new javax.swing.JCheckBox();
        cNacionalidad = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        tNombre = new javax.swing.JTextField();
        tTipo = new javax.swing.JTextField();
        tNacionalidad = new javax.swing.JTextField();
        tDuracion = new javax.swing.JTextField();
        tDificultad = new javax.swing.JTextField();
        tEnergia = new javax.swing.JTextField();
        cEnergia = new javax.swing.JCheckBox();
        bBuscar = new javax.swing.JButton();
        bCerrar = new javax.swing.JButton();
        cDuracion = new javax.swing.JCheckBox();
        cDificultad = new javax.swing.JCheckBox();
        dialogoBuscarNombre = new javax.swing.JDialog();
        nombreRecetaBuscar = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        Buscar2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();

        dialogoBuscarCriterios.setTitle("Buscar recetas por criterios");
        dialogoBuscarCriterios.setMinimumSize(new java.awt.Dimension(370, 300));
        dialogoBuscarCriterios.setResizable(false);

        cTipo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cTipoActionPerformed(evt);
            }
        });

        jLabel1.setText("Seleccione el criterio o criterios de busqueda:");

        jLabel2.setText("Nombre:");

        jLabel3.setText("Tipo:");

        jLabel4.setText("Nacionalidad:");

        jLabel5.setText("Duración:");

        jLabel6.setText("Dificultad:");

        jLabel7.setText("Energía:");

        tNombre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tNombreActionPerformed(evt);
            }
        });

        bBuscar.setText("Buscar");
        bBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bBuscarActionPerformed(evt);
            }
        });

        bCerrar.setText("Cancelar");
        bCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bCerrarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dialogoBuscarCriteriosLayout = new javax.swing.GroupLayout(dialogoBuscarCriterios.getContentPane());
        dialogoBuscarCriterios.getContentPane().setLayout(dialogoBuscarCriteriosLayout);
        dialogoBuscarCriteriosLayout.setHorizontalGroup(
            dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addContainerGap(177, Short.MAX_VALUE))
                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                        .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                                .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel7))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, dialogoBuscarCriteriosLayout.createSequentialGroup()
                                        .addComponent(tEnergia, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE))
                                    .addComponent(tTipo, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                                    .addComponent(tDificultad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                                    .addComponent(tDuracion, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                                    .addComponent(tNacionalidad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE))
                                .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(cNombre))
                                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(cEnergia))
                                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(cNacionalidad))
                                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(cTipo))
                                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(cDuracion))
                                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(cDificultad))))
                            .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                                .addGap(95, 95, 95)
                                .addComponent(bBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(bCerrar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 141, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())))
        );
        dialogoBuscarCriteriosLayout.setVerticalGroup(
            dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                        .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(tNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(tTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(tNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(tDuracion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cDuracion)))
                    .addGroup(dialogoBuscarCriteriosLayout.createSequentialGroup()
                        .addComponent(cNombre)
                        .addGap(8, 8, 8)
                        .addComponent(cTipo)
                        .addGap(5, 5, 5)
                        .addComponent(cNacionalidad)))
                .addGap(4, 4, 4)
                .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tDificultad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(cDificultad))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel7)
                        .addComponent(tEnergia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(cEnergia))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(dialogoBuscarCriteriosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bCerrar)
                    .addComponent(bBuscar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        dialogoBuscarNombre.setMinimumSize(new java.awt.Dimension(400, 120));
        dialogoBuscarNombre.setName("Busqueda por Nombre"); // NOI18N
        dialogoBuscarNombre.setResizable(false);

        jLabel8.setText("Nombre de la receta:");

        Buscar2.setText("Buscar");
        Buscar2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Buscar2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dialogoBuscarNombreLayout = new javax.swing.GroupLayout(dialogoBuscarNombre.getContentPane());
        dialogoBuscarNombre.getContentPane().setLayout(dialogoBuscarNombreLayout);
        dialogoBuscarNombreLayout.setHorizontalGroup(
            dialogoBuscarNombreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoBuscarNombreLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel8)
                .addGap(18, 18, 18)
                .addGroup(dialogoBuscarNombreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Buscar2)
                    .addComponent(nombreRecetaBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(67, Short.MAX_VALUE))
        );
        dialogoBuscarNombreLayout.setVerticalGroup(
            dialogoBuscarNombreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoBuscarNombreLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dialogoBuscarNombreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(nombreRecetaBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Buscar2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("Buscar por Criterios");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Busqueda Alfabetica");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Buscar por Nombre");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Menu Semanal");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(140, 140, 140)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton4)
                    .addComponent(jButton3)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addContainerGap(129, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton1, jButton2, jButton3, jButton4});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(86, 86, 86)
                .addComponent(jButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addGap(46, 46, 46)
                .addComponent(jButton4)
                .addContainerGap(64, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
    dialogoBuscarCriterios.setVisible(true);
}//GEN-LAST:event_jButton1ActionPerformed

private void cTipoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cTipoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cTipoActionPerformed

private void bCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bCerrarActionPerformed
// TODO add your handling code here:
    dialogoBuscarCriterios.setVisible(false);
}//GEN-LAST:event_bCerrarActionPerformed

private Vector<Receta> cargarDatos(){
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("recetasUnit");
    EntityManager em;
    em = emf.createEntityManager();
    em.setFlushMode(FlushModeType.AUTO);
    Vector<Receta> recetas2 = new Vector<Receta>(0,1);
    recetas2 = (Vector<Receta>)em.createQuery("SELECT r FROM Receta r WHERE r.id>0").getResultList();
    Collections.sort(recetas2);
    return recetas2;
}
private Vector<Receta> copiarSinDuplicado(Vector<Receta>r1, Vector<Receta>r2){
    Vector<Receta> r3 = new Vector<Receta>(0,1);
    int i=0;
    r3.addAll(r1);
    while(i < r2.size()){
        if(!r3.contains(r2.elementAt(i)))
            r3.add(r2.elementAt(i));
        i++;
    }
    return r3;
}
private void bBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bBuscarActionPerformed
// TODO add your handling code here:
    /*Vector<Receta> recetas = new Vector<Receta>(0,1);
    Vector<Receta> buscados = new Vector<Receta>(0,1);
    Vector<Receta> resultado = new Vector<Receta>(0,1);
    mostrarReceta busqueda = new mostrarReceta();
    recetas = cargarDatos();
    //Componemos el vector a partir de los distintos criterios de busqueda
    if(cNombre.isSelected() && tNombre.getText() != null);
    if(cTipo.isSelected() && tTipo.getText() != null){
        buscados.addAll(new main().searchTipo(recetas, tTipo.getText()));
        resultado = copiarSinDuplicado(resultado,buscados);
        buscados.clear();
    }
    if(cNacionalidad.isSelected() && tNacionalidad.getText() != null){
        buscados.addAll(new main().searchNacionalidad(recetas, tNacionalidad.getText()));
        resultado = copiarSinDuplicado(resultado,buscados);
        buscados.clear();
    }
    if(cDuracion.isSelected() && tDuracion.getText() != null){
        buscados.addAll(new main().searchDuracion(recetas, Integer.parseInt(tDuracion.getText())));
        resultado = copiarSinDuplicado(resultado,buscados);
        buscados.clear();
    }
    if(cDificultad.isSelected() && tDificultad.getText() != null){
        buscados.addAll(new main().searchDificultad(recetas, tDificultad.getText()));
        resultado = copiarSinDuplicado(resultado,buscados);
        buscados.clear();
    }
    if(cEnergia.isSelected() && tEnergia.getText() != null){
        buscados.addAll(new main().searchKcal(recetas, Integer.parseInt(tEnergia.getText())));
        resultado = copiarSinDuplicado(resultado,buscados);
        buscados.clear();
    }
    
    if(resultado != null && !resultado.isEmpty()){
        dialogoBuscarCriterios.setVisible(false);
        busqueda.setRecetas(resultado);
        busqueda.setVisible(true);
    }*/
    String s1;
    if(cNombre.isSelected())s1 = tNombre.getText();
    else s1 = null;
    
    String s2;
    if(cTipo.isSelected())s2 = tTipo.getText();
    else s2 = null;
    
    String s3;
    if(cNacionalidad.isSelected())s3 = tNacionalidad.getText();
    else s3 = null;
    
    String s4;
    int i=0;
    if(cDuracion.isSelected()){
        s4 = tDuracion.getText();
        i = Integer.parseInt(s4);
    }
    
    String s5;
    if(cDificultad.isSelected())s5 = tDificultad.getText();
    else s5 = null;
    
    String s6;
    int j=0;
    if(cEnergia.isSelected()){
        s6 = tEnergia.getText();
        j = Integer.parseInt(s6);
    }
    
    mostrarReceta m = new mostrarReceta();
    Vector<Receta>rec=new Vector<Receta>(0,1);
    rec = new main().searchByCriteria(s1, s2, i, s5, s3, j);
    m.setRecetas(rec);
    m.setVisible(true);
    dialogoBuscarCriterios.setVisible(false);
}//GEN-LAST:event_bBuscarActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    dialogoBuscarNombre.setVisible(true);
}//GEN-LAST:event_jButton3ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    Vector<Receta> recetas = new Vector<Receta>(0,1);
    recetas = cargarDatos();
    mostrarReceta mostrar = new mostrarReceta();

    Collections.sort(recetas);
    mostrar.setRecetas(recetas);
    mostrar.setVisible(true);
}//GEN-LAST:event_jButton2ActionPerformed

private void Buscar2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Buscar2ActionPerformed
// TODO add your handling code here:
    String nombre = nombreRecetaBuscar.getText();
    Vector<Receta> recetas = new Vector<Receta>(0,1);
    Vector<Receta> buscados = new Vector<Receta>(0,1);
    recetas = cargarDatos();
    mostrarReceta mostrar = new mostrarReceta();

    int i=0;
    while(i < recetas.size()){
        if(recetas.elementAt(i).getNombre().contains(nombre))
            buscados.add(recetas.elementAt(i));
        i++;
    }
    if(!buscados.isEmpty()){
        dialogoBuscarNombre.setVisible(false);
        mostrar.setRecetas(buscados);
        mostrar.setVisible(true);
    }
    else System.out.println("No se encontro ninguna receta");
}//GEN-LAST:event_Buscar2ActionPerformed

private void tNombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tNombreActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_tNombreActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
//VAmos a hacer el menu semanal
    Vector<Receta> recetas = new Vector<Receta>(0,1);
    Vector<Receta> buscados = new Vector<Receta>(0,1);
    recetas = cargarDatos();
    Menu m = new Menu();
    buscados = m.MenuSemanal(recetas);
    
    menuSemanal ms = new menuSemanal();
    ms.setDatos(buscados);
    ms.setVisible(true);
}//GEN-LAST:event_jButton4ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ventanaPrincipal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Buscar2;
    private javax.swing.JButton bBuscar;
    private javax.swing.JButton bCerrar;
    private javax.swing.JCheckBox cDificultad;
    private javax.swing.JCheckBox cDuracion;
    private javax.swing.JCheckBox cEnergia;
    private javax.swing.JCheckBox cNacionalidad;
    private javax.swing.JCheckBox cNombre;
    private javax.swing.JCheckBox cTipo;
    private javax.swing.JDialog dialogoBuscarCriterios;
    private javax.swing.JDialog dialogoBuscarNombre;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JTextField nombreRecetaBuscar;
    private javax.swing.JTextField tDificultad;
    private javax.swing.JTextField tDuracion;
    private javax.swing.JTextField tEnergia;
    private javax.swing.JTextField tNacionalidad;
    private javax.swing.JTextField tNombre;
    private javax.swing.JTextField tTipo;
    // End of variables declaration//GEN-END:variables

}
